<?php


namespace app\adminapi\validate\goods;

use app\adminapi\validate\Base;

class TagValidate extends Base
{
    protected $rule = [
        'id'          => 'require',
        'name'        => 'require|unique:goods_tag,name',
        'sort'        => 'number|egt:0',
        'status'      => 'number|in:0,1',
        'description' => 'max:255',
    ];

    protected $message = [
        'id.require'      => 'id_required',
        'name.require'    => 'name_required',
        'name.unique'     => 'name_unique',
        'sort.number'     => 'sort_number',
        'sort.egt'        => 'sort_egt',
        'status.number'   => 'status_number',
        'status.in'       => 'status_in',
        'description.max' => 'description_max',
    ];

    // edit
    public function sceneEdit()
    {
        return $this->only(['id', 'name', 'sort', 'status', 'description']);
    }

    // add
    public function sceneAdd()
    {
        return $this->only(['name', 'sort', 'status', 'description']);
    }

    // delete
    public function sceneDelete()
    {
        return $this->only(['id']);
    }

}